package com.ruoyi.web.controller.wbgame;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wbgame.domain.WbStuAnswer;
import com.ruoyi.wbgame.service.IWbStuAnswerService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 学生回答的选项Controller
 * 
 * @author guguofu
 * @date 2021-04-16
 */
@Controller
@RequestMapping("/wbgame/stuAnswer")
public class WbStuAnswerController extends BaseController
{
    private String prefix = "wbgame/stuAnswer";

    @Autowired
    private IWbStuAnswerService wbStuAnswerService;

    @RequiresPermissions("wbgame:stuAnswer:view")
    @GetMapping()
    public String stuAnswer()
    {
        return prefix + "/stuAnswer";
    }

    /**
     * 查询学生回答的选项列表
     */
    @RequiresPermissions("wbgame:stuAnswer:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(WbStuAnswer wbStuAnswer)
    {
        startPage();
        List<WbStuAnswer> list = wbStuAnswerService.selectWbStuAnswerList(wbStuAnswer);
        return getDataTable(list);
    }

    /**
     * 导出学生回答的选项列表
     */
    @RequiresPermissions("wbgame:stuAnswer:export")
    @Log(title = "学生回答的选项", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(WbStuAnswer wbStuAnswer)
    {
        List<WbStuAnswer> list = wbStuAnswerService.selectWbStuAnswerList(wbStuAnswer);
        ExcelUtil<WbStuAnswer> util = new ExcelUtil<WbStuAnswer>(WbStuAnswer.class);
        return util.exportExcel(list, "stuAnswer");
    }

    /**
     * 新增学生回答的选项
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存学生回答的选项
     */
    @RequiresPermissions("wbgame:stuAnswer:add")
    @Log(title = "学生回答的选项", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(WbStuAnswer wbStuAnswer)
    {
        return toAjax(wbStuAnswerService.insertWbStuAnswer(wbStuAnswer));
    }

    /**
     * 修改学生回答的选项
     */
    @GetMapping("/edit/{studentId}")
    public String edit(@PathVariable("studentId") Long studentId, ModelMap mmap)
    {
        WbStuAnswer wbStuAnswer = wbStuAnswerService.selectWbStuAnswerById(studentId);
        mmap.put("wbStuAnswer", wbStuAnswer);
        return prefix + "/edit";
    }

    /**
     * 修改保存学生回答的选项
     */
    @RequiresPermissions("wbgame:stuAnswer:edit")
    @Log(title = "学生回答的选项", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(WbStuAnswer wbStuAnswer)
    {
        return toAjax(wbStuAnswerService.updateWbStuAnswer(wbStuAnswer));
    }

    /**
     * 删除学生回答的选项
     */
    @RequiresPermissions("wbgame:stuAnswer:remove")
    @Log(title = "学生回答的选项", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(wbStuAnswerService.deleteWbStuAnswerByIds(ids));
    }
}
